import request from "@/utils/request"

export interface ChargeData {
  beforeElectricMoney: number
  beforeServiceMoney: number
  chargeTime: number
  day: string,
  electricMoney: number
  fengPower: number
  guPower: number
  jianPower: number
  month: number
  orderNum: number
  orgId: number
  pingPower: number
  power: number
  serviceMoney: number
  shenPower: number
  stationId: string,
  stationName: string,
  stubNum: number
  stubType: number
  topPower: number
  totalMoney: number
}

export async function queryChargeData(data: {day: string}) {
  return request<ChargeData>('/app/manager/stationOrderCount', {data})
}

export interface TerminalStatus {
  acChargeNum: number
  acErrorNum: number
  acFreeNum: number
  acNum: number
  acOccupyNum: number
  acOffLineNum: number
  acOtherNum: number
  dcChargeNum: number
  dcErrorNum: number
  dcFreeNum: number
  dcNum: number
  dcOccupyNum: number
  dcOffLineNum: number
  dcOtherNum: number
  equipmentNum: number
  kw: number
  kwBig: number
  kwSmall: number
  realKw: number
  orgId: number
  score: number
  stationId: string
  stationName: string
}

export async function queryTerminalStatus(data: {stationId?: string}) {
  return request<TerminalStatus>('/app/manager/stubNumCount', {data})
}

export interface ChargeDataAnalysis {
  day: string
  /** 订单数 */
  num: number
  /** 电量（度） */
  power: number
  /** 充电费 */
  totalMoney: number
  /** 服务费 */
  serviceMoney: number
  /** 时段充电量分析, 该字段接口没有，需要自己转换 */
  hourPower?: number
}

export enum QueryChargeDataAnalysisParamsStubType {
  全部 = 0,
  快充 = 1,
  慢充 = 2,
}
export enum QueryChargeDataAnalysisParamsTimeType {
  按月 = 1,
  按天 = 2,
}

export interface QueryChargeDataAnalysisParams {
  stationId?: string
  timeType: QueryChargeDataAnalysisParamsTimeType
  beginDay: string
  endDay: string
  stubType?: QueryChargeDataAnalysisParamsStubType
  infoType: 1 | 2 // 1-不同时段充电量，2-其他数据
}

export async function queryChargeDataAnalysis(data: QueryChargeDataAnalysisParams, token?: string) {
  return request<ChargeDataAnalysis[]>('/app/manager/time/chargeCount', {data, token})
}

export interface DQueryStationListParams extends PaginationParams {
  cityId?: number
}